import Vue from 'vue'
import VueRouter from 'vue-router'
import Test from "../views/Test";
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home1',
    meta: {
      index: 1
    },
    component: () => import('../views/home/index')
  },
  {
    path: '/category',
    name: 'category',
    meta: {
      index: 1
    },
    component: () => import('../views/category/index'),
  },
  {
    path: '/user',
    name: 'user',
    meta: {
      index: 1,
      requireAuth: true
    },
    component: () => import( '../views/user/index'),
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      index: 2
    },
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/address',
    name: 'address',
    meta: {
      index: 2,
      requireAuth: true
    },
    component: () => import('../views/address/index'),
  },
  {
    path: '/address-edit',
    name: 'address-edit',
    meta: {
      index: 3,
      requireAuth: true
    },
    component: () => import('../views/address/components/addressDetail'),
  },
  {
    path: '/order',
    name: 'order',
    meta: {
      index: 2,
      requireAuth: true
    },
    component: () => import('../views/order/index'),
  },
  {
    path: '/order-detail',
    name: 'order-detail',
    meta: {
      index: 3,
      requireAuth: true
    },
    component: () => import('../views/order/commponent/orderDetail'),
  },
  {
    path: '/product/:id',
    name: 'product',
    meta: {
      index: 3
    },
    component: () => import('../views/product/product-detail'),
  },
  {
    path: '/product-list',
    name: 'product-list',
    meta: {
      index: 2
    },
    component: () => import('../views/product/product-list'),
  },
  {
    path: '/cart',
    name: 'cart',
    meta: {
      index: 1,
      requireAuth: true
    },
    component: () => import('../views/cart/index'),
  },
  {
    path: '/create-order',
    name: 'create-order',
    meta: {
      index: 2,
      requireAuth: true
    },
    component: () => import('../views/order/commponent/orderCreate'),
  },
  {
    path: '/setting',
    name: 'setting',
    meta: {
      index: 2,
      requireAuth: true
    },
    component: () => import('../views/user/userSetting'),
  },
  {
    path: '/product-history',
    name: 'productHistory',
    meta: {
      index: 2,
      requireAuth: true
    },
    component: () => import('../views/history/productHistory')
  },

  {
    path: '/test',
    name: 'Test',
    component: Test
  },
  {
    path: '/watterfall',
    name: 'WatterFall',
    component: () => import('../views/WaterFall')
  },
  {
    path: '/paysuccess',
    name: 'PaySuccess',
    component: () => import('../views/order/commponent/paySuccess')
  }
]

// const router = new VueRouter({
//   routes
// })
//
// export default router

export default new VueRouter({
  mode: 'history',
  scrollBehavior: () => ({y: 0}),
  routes: routes
})
